/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Modals

.composer {
  // Kill the scroll on the body
  .modal-open {
    overflow: hidden;
  }

  // Container that the modal scrolls within
  .modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100000;
    display: none;
    overflow: auto;
    outline: 0;
    &.fade .modal-dialog {
      @include transition(transform);
      transform: translate(0, -25%);
    }
    &.show .modal-dialog {
      transform: translate(0, 0);
    }
  }
  .modal-open .modal {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .modal-dialog {
    margin: 10vh auto;
    display: table;
    min-width: 700px;
    max-width: 800px;
  }

  .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: $white;
    background-clip: padding-box;
    border: 1px solid $fourth-highlight;
    border-radius: 3px;
    outline: 0;
  }

  // Modal background
  .modal-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    background-color: $black;

    // Fade for backdrop
    &.fade {
      opacity: 0;
    }
    &.show {
      opacity: 0.7;
    }
  }

  // Modal header
  .modal-header {
    display: flex;
    align-items: center;
    padding: $space-medium;
    background-color: $third-highlight;

    svg + h1 {
      margin-left: $space-medium;
    }

    .modal-exit {
      position: absolute;
      top: 0px;
      right: $space-smedium;
      color: $primary-text;
    }
  }

  // Modal body
  .modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: $space-medium;
    display: flex;
    flex-direction: column;

    // TODO belongs in a common _forms.scss file?
    form {
      padding-right: 20%;

      div {
        margin-bottom: 1rem;

        &.justified-input {
          display: flex;
          justify-content: space-between;
          align-items: center;

          label {
            flex: 1;

            &.required {
              // TODO should have some weight variables?
              font-weight: 700;
            }
          }

          input, select {
            flex: 5;
            margin: 0;
          }
        }
      }
    }
  }

  // Footer (for actions)
  footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: $space-medium;
    background-color: $third-highlight;

    // Easily place margin between footer elements
    // > :not(:first-child) {
    //   margin-left: .25rem;
    // }
    // > :not(:last-child) {
    //   margin-right: .25rem;
    // }
  }

  // Measure scrollbar width for padding body during modal show/hide
  .modal-scrollbar-measure {
    position: absolute;
    top: -9999px;
    width: 50px;
    height: 50px;
    overflow: scroll;
  }
}
